use serde::Deserialize;

#[derive(Deserialize)]
#[serde(rename_all(deserialize = "kebab-case"))]
pub struct ServerConfig {
    /// 端口号
    port: Option<u16>,
    /// 接口请求超时时间
    timeout: Option<u16>,
}

impl Default for ServerConfig {
    fn default() -> Self {
        Self {
            port: None,
            timeout: None,
        }
    }
}

impl ServerConfig {
    pub fn port(&self) -> u16 {
        self.port.unwrap_or(3000)
    }

    pub fn timeout(&self) -> u16 {
        self.timeout.unwrap_or(600)
    }
}
